package com.open.common.model.po;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

import java.io.Serializable;
import java.util.List;
import java.util.Map;


/**
 * Entity支持类
 */
public abstract class BaseEntity<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 删除标记（0：正常；1：删除；2：审核；）
     */
    public static final String DEL_FLAG_NORMAL = "0";
    public static final String DEL_FLAG_DELETE = "1";
    public static final String DEL_FLAG_AUDIT = "2";

    protected String id; // 实体编号（唯一标识）

    protected Page<T> page; // 当前实体分页对象

    protected Map<String, String> sqlMap; // 自定义SQL（SQL标识，SQL内容）

    protected String sort; // 排序顺序

    protected String fields; // 排序字段

    protected String start; // 返回记录的开始位置

    protected String end; // 返回记录的结束位置

    protected String limit; // 返回记录的数量

    protected String currUsrId;

    protected String currUsrNam;

    protected List<String> roleIdList; // 用户角色列表

    public BaseEntity() {

    }

    public BaseEntity(String id) {
        this();
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Map<String, String> getSqlMap() {
        return sqlMap;
    }

    public void setSqlMap(Map<String, String> sqlMap) {
        this.sqlMap = sqlMap;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getFields() {
        return fields;
    }

    public void setFields(String fields) {
        this.fields = fields;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public String getLimit() {
        return limit;
    }

    public void setLimit(String limit) {
        this.limit = limit;
    }

    public String getCurrUsrId() {
        return currUsrId;
    }

    public void setCurrUsrId(String currUsrId) {
        this.currUsrId = currUsrId;
    }

    public String getCurrUsrNam() {
        return currUsrNam;
    }

    public void setCurrUsrNam(String currUsrNam) {
        this.currUsrNam = currUsrNam;
    }

    public List<String> getRoleIdList() {
        return roleIdList;
    }

    public void setRoleIdList(List<String> roleIdList) {
        this.roleIdList = roleIdList;
    }

    public Page<T> getPage() {
        if (page == null) {
            page = new Page<T>();
        }
        return page;
    }

    public Page<T> setPage(Page<T> page) {
        this.page = page;
        return page;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

}
